package connection;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import android.util.Log;

public class InternetConnection implements Connection {
	private static final String DEBUG_CLOSE = "SocketConnection.close()";
	
	private int port;
	private String server;
	private Socket socket = null;

	public InternetConnection(String host, int port) throws UnknownHostException, IOException {
		this.server = host;
		this.port = port;
		this.connect();
	}

	private void connect() throws UnknownHostException, IOException{
		socket = new Socket(server, port);
	}

	@Override
	public void close() {
		try {
			this.socket.close();
		} catch (IOException e) {
			Log.e(DEBUG_CLOSE, e.toString());
		}
	}

	@Override
	public Socket getSocket() {
		return this.socket;
	}
}
